import { useHistory } from 'react-router-dom'
import { NavBar } from 'antd-mobile'

import styles from './index.module.scss'
import useInitialState from '@/hooks/useInitialState'
import { getresultlist } from '@/store/actions/search'
import ArticleItem from '@/pages/Home/components/ArticleItem/ArticleItem'

const Result = () => {
  const history = useHistory()
  const id = new URLSearchParams(history.location.search).get('keyword')!
  const { results: list } = useInitialState(() => getresultlist(id), 'search')
  console.log(list, 'list');
  return (
    <div className={styles.root}>
      <NavBar onBack={() => history.go(-1)}>搜索结果</NavBar>
      <div className="article-list">
        <div className="article-item">
          <div className="article-list">
            {list.map((item) => (
              <ArticleItem
                key={item.art_id}
                article={item}
              ></ArticleItem>
            ))}
          </div>
        </div>
      </div>
    </div>
  )
}

export default Result